package at.theengine.android.gs4android;

import java.io.InputStream;

import android.util.Log;
import at.theengine.android.botstorage.BotStorageException;
import at.theengine.android.botstorage.StorageService;
import at.theengine.android.botstorage.gsobjects.Bucket;
import at.theengine.android.botstorage.gsobjects.File;
import at.theengine.android.botstorage.gsobjects.Folder;
import at.theengine.android.botstorage.gsobjects.GsObject;
import at.theengine.android.botstorage.gsobjects.GsObjects;
import at.theengine.android.botstorage.gsobjects.GsObject.ObjectType;

public class GSDataAdapter {

	private StorageService gsService;
	
	public GSDataAdapter(String key, String secret){
		gsService = new StorageService(key, secret);
	}
	
	public String[] getBucketNames() throws BotStorageException {
		//get all Buckets
		Bucket[] buckets = gsService.getBuckets();
			
		//get all Bucketnames
		String[] bucketNames = new String[buckets.length];
		for(int i = 0; i < buckets.length;i++){
			bucketNames[i] = buckets[i].getName();
		}
		
		return bucketNames;
	}
	
	public GsObjects getObjectNames(String bucket,String path) throws BotStorageException{
		//get all Objects
		return gsService.getGsObjects(bucket,path);
	}
	
	public InputStream downloadGsFile(String bucket, String path) throws BotStorageException{
		return gsService.downloadGsFile(bucket, path);
	}
	
}
